namespace RBAC.Write.Api.Controllers.ProcessManagements
{
    using Microsoft.AspNetCore.Mvc;
    using RBAC.Write.Api.Application.Dto;
    using RBAC.Write.Api.Application.Interfaces;

    /// <summary>
    /// 生产工单（写侧）控制器：创建、更新、报工。
    /// </summary>
    [ApiController]
    [Route("api/process-management/production-work-orders")]
    public class ProductionWorkOrdersController : ControllerBase
    {
        private readonly IProductionWorkOrderWriteService _svc;
        public ProductionWorkOrdersController(IProductionWorkOrderWriteService svc)
        {
            _svc = svc;
        }

        /// <summary>
        /// 创建生产工单。
        /// </summary>
        [HttpPost]
        public IActionResult Create([FromBody] CreateWorkOrderCommandDto cmd)
        {
            var res = _svc.CreateProductionWorkOrder(cmd);
            return Ok(res);
        }

        /// <summary>
        /// 更新生产工单。
        /// </summary>
        [HttpPut]
        public IActionResult Update([FromBody] UpdateWorkOrderCommandDto cmd)
        {
            var res = _svc.UpdateProductionWorkOrder(cmd);
            return Ok(res);
        }

        /// <summary>
        /// 提交生产报工。
        /// </summary>
        [HttpPost("report")]
        public IActionResult SubmitReport([FromBody] SubmitProductionReportDto cmd)
        {
            var res = _svc.SubmitProductionReport(cmd);
            return Ok(res);
        }
    }
}
